package de.schlinke_marius.fragments;

import android.app.Activity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.actionbarsherlock.app.SherlockFragment;

import de.schlinke_marius.R;
import de.schlinke_marius.activities.MainTabActivity;

public class HomeFragment extends SherlockFragment implements OnClickListener{
	
	private MainTabActivity activity = null;
	
	/*
	 *
	 * UI elements
	 */
	private Button btExamples = null;
	private Button btConsulting = null;
	
	@Override
	public void onAttach(Activity activity) {
		initializeReferences(activity);
		super.onAttach(activity);
	}
	
	private void initializeReferences(Activity activity) {
		this.activity = (MainTabActivity) activity;
	}

	@Override
	public void onSaveInstanceState(Bundle outState) {
		super.onSaveInstanceState(outState);
		if (outState.isEmpty()) {
			outState.putBoolean("bug:fix", true);
		}
	}
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		//Inflate the layout for this fragment
		return inflater.inflate(R.layout.mainview, container, false);
	}
	@Override
	public void onViewCreated(View view, Bundle savedInstanceState) {
		btExamples = (Button) view.findViewById(R.id.btExamplesNavigation);
		btConsulting = (Button) view.findViewById(R.id.btCosultingNavigation);
		btExamples.setOnClickListener(this);
		btConsulting.setOnClickListener(this);

	}

	@Override
	public void onClick(View v) {
		
		switch (v.getId()) {
		
		case R.id.btExamplesNavigation : activity.selectTab(1); break;
		case R.id.btCosultingNavigation : activity.selectTab(2); break;
		}
		
	}

}
